86d3c91162347d09f62971809b463ac7ce07f31c,opennms-webapp/src/main/java/org/opennms/web/controller/admin/thresholds/ThresholdController.java,ThresholdController,finishThresholdFilterEdit,#HttpServletRequest#,234
Before Change
}
private ModelAndView finishThresholdFilterEdit(HttpServletRequest request) throws ServletException {
ThresholdingConfigFactory configFactory=ThresholdingConfigFactory.getInstance();
ModelAndView modelAndView;
int thresholdIndex=Integer.parseInt(request.getParameter("thresholdIndex"));
String groupName=request.getParameter("groupName");
String submitAction=request.getParameter("submitAction");
Threshold threshold=configFactory.getGroup(groupName).getThreshold(thresholdIndex);
modelAndView=new ModelAndView("admin/thresholds/editThreshold");
// Save Threshold Filters on HTTP Session in order to restore the original
// list if user clicks on "Cancel"
List saved = (List)request.getSession(true).getAttribute("savedFilters");
if (saved == null || saved.size() == 0) {
saved = new ArrayList(threshold.getResourceFilterCollection());
request.getSession(false).setAttribute("savedFilters", saved);
}
String stringIndex = request.getParameter("filterSelected");
int filterIndex = stringIndex != null && !stringIndex.equals("") ? Integer.parseInt(stringIndex) - 1 : 0;
if (ADDFILTER_BUTTON_TITLE.equals(submitAction)) {
String field = request.getParameter("filterField");
String content = request.getParameter("filterRegexp");
if (field != null && !field.equals("") && content != null && !content.equals("")) {
ResourceFilter filter = new ResourceFilter();
filter.setField(field);
filter.setContent(content);
threshold.addResourceFilter(filter);
}
} else if (DELETE_BUTTON_TITLE.equals(submitAction)) {
threshold.getResourceFilterCollection().remove(filterIndex);
} else if (EDIT_BUTTON_TITLE.equals(submitAction)) {
modelAndView.addObject("filterSelected", request.getParameter("filterSelected"));
} else if (UPDATE_BUTTON_TITLE.equals(submitAction)) {
ResourceFilter filter = (ResourceFilter)threshold.getResourceFilterCollection().get(filterIndex);
filter.setField(request.getParameter("updateFilterField"));
filter.setContent(request.getParameter("updateFilterRegexp"));
} else if (MOVEUP_BUTTON_TITLE.equals(submitAction)) {
moveThresholdFilter(threshold, filterIndex, filterIndex - 1);
} else if (MOVEDOWN_BUTTON_TITLE.equals(submitAction)) {
moveThresholdFilter(threshold, filterIndex, filterIndex + 1);
}
commonFinishEdit(request, threshold);
threshold.setDsName(request.getParameter("dsName"));
String isNew=request.getParameter("isNew");
if("true".equals(isNew))
modelAndView.addObject("isNew", true);
modelAndView.addObject("threshold", threshold);
modelAndView.addObject("thresholdIndex", thresholdIndex);
modelAndView.addObject("groupName", groupName);
addStandardEditingBits(modelAndView);
After Change
private ModelAndView finishThresholdFilterEdit(HttpServletRequest request, Basethresholddef threshold) throws ServletException {
boolean isExpression = threshold instanceof Expression;
int thresholdIndex;
if (isExpression) {
thresholdIndex = Integer.parseInt(request.getParameter("expressionIndex"));
} else {
thresholdIndex = Integer.parseInt(request.getParameter("thresholdIndex"));
}
ModelAndView modelAndView;
if (isExpression) {
modelAndView = new ModelAndView("admin/thresholds/editExpression");
} else {
modelAndView = new ModelAndView("admin/thresholds/editThreshold");
}
List<ResourceFilter> saved = getFilterList(request, true);
if (saved == null || saved.size() == 0) {
saved = new ArrayList<ResourceFilter>(threshold.getResourceFilterCollection());
setFilterList(request, saved);
}
String stringIndex = request.getParameter("filterSelected");
int filterIndex = stringIndex != null && !stringIndex.equals("") ? Integer.parseInt(stringIndex) - 1 : 0;
/*
* Save Threshold Filters on HTTP Session in order to restore the original list if user clicks on "Cancel"
*/
String submitAction = request.getParameter("submitAction");
if (ADDFILTER_BUTTON_TITLE.equals(submitAction)) {
String field = request.getParameter("filterField");
String content = request.getParameter("filterRegexp");
if (field != null && !field.equals("") && content != null && !content.equals("")) {
ResourceFilter filter = new ResourceFilter();
filter.setField(field);
filter.setContent(content);
threshold.addResourceFilter(filter);
}
} else if (DELETE_BUTTON_TITLE.equals(submitAction)) {
threshold.getResourceFilterCollection().remove(filterIndex);
} else if (EDIT_BUTTON_TITLE.equals(submitAction)) {
modelAndView.addObject("filterSelected", request.getParameter("filterSelected"));
} else if (UPDATE_BUTTON_TITLE.equals(submitAction)) {
ResourceFilter filter = (ResourceFilter)threshold.getResourceFilterCollection().get(filterIndex);
filter.setField(request.getParameter("updateFilterField"));
filter.setContent(request.getParameter("updateFilterRegexp"));
} else if (MOVEUP_BUTTON_TITLE.equals(submitAction)) {
moveThresholdFilter(threshold, filterIndex, filterIndex - 1);
} else if (MOVEDOWN_BUTTON_TITLE.equals(submitAction)) {
moveThresholdFilter(threshold, filterIndex, filterIndex + 1);
}
commonFinishEdit(request, threshold);
if (isExpression) {
((Expression)threshold).setExpression(request.getParameter("expression"));
} else {
((Threshold)threshold).setDsName(request.getParameter("dsName"));
}
String isNew=request.getParameter("isNew");
if("true".equals(isNew))
modelAndView.addObject("isNew", true);
if (isExpression) {
modelAndView.addObject("expression", threshold);
modelAndView.addObject("expressionIndex", thresholdIndex);
} else {
modelAndView.addObject("threshold", threshold);
modelAndView.addObject("thresholdIndex", thresholdIndex);
}
modelAndView.addObject("groupName", request.getParameter("groupName"));
addStandardEditingBits(modelAndView);
return modelAndView;